Cybersecurity Attacks – Red Team Strategies by Johann Rehberger

Cybersecurity Attacks – Red Team Strategies by Johann Rehberger

Author:Johann Rehberger
Language: eng
Format: epub
Publisher: Packt Publishing Pvt Ltd
Published: 2020-03-30T00:00:00+00:00


Figure 6.27: Loading CSV files into the graph database

Here we see the successful load of a CSV file so that it can be processed by Neo4j. However, at this point, we have not yet created nodes in the graph database. Let's look at how to do that.

Loading CSV data and creating nodes and relationships

The following Cypher statement shows how to successfully load the machines.csv file into the graph database, create nodes for services and computer, and create relationships between these nodes:

LOAD CSV WITH HEADERS FROM "file:///machines.csv" AS line

FIELDTERMINATOR ';'

MERGE (s:Services {port: line.PORT, service: line.SERVICE, hostname: line.FQDN})

MERGE (c:Computer {hostname: line.FQDN, ip: line.IP, operatingsystem: line.OS})

MERGE (c)-[e:EXPOSES]->(s)

Afterward, we can query the graph using this:

MATCH graph=(c:Computer)-[]-(s:Services) RETURN services

This will show the computer nodes and what services each node exposes:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.